
#if SILVERLIGHT

using Qdb;
using Qdb.Config;
using Qdb.IO;

namespace QdbUnit.Extensions.Fixtures
{
	public class SilverlightFixture : AbstractSoloQdbFixture
	{
		protected override void DoClean()
		{
			if (null != _storage)
			{
				_storage.Delete(DatabaseFileName);
			}
		}

		public override string Label()
		{
			return BuildLabel("Silverlight Solo");
		}

		public override void Defragment()
		{
			Defragment(DatabaseFileName);
		}

		protected override IObjectContainer CreateDatabase(IConfiguration config)
		{
			return QdbFactory.OpenFile(config, DatabaseFileName);
		}

		protected override IConfiguration NewConfiguration()
		{
			IConfiguration config = base.NewConfiguration();
			config.Storage = _storage;

			return config;
		}

		public override bool Accept(System.Type clazz)
		{
			if (typeof(IOptOutSilverlight).IsAssignableFrom(clazz)) return false;
			return base.Accept(clazz);
		}

		private const string DatabaseFileName = "SilverlightDatabase.qdb";
		private readonly IsolatedStorageStorage _storage = new IsolatedStorageStorage();
	}
}

#endif